import java.util.*;

public class LinkedHashSetTest {
    public static void t1(){
        List list = new ArrayList();
        Set set = new LinkedHashSet();
        Scanner sc = new Scanner(System.in);
        System.out.print("输入字符串:");
        String str = sc.next();
        Map map = new HashMap();
        char[] chars = str.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            set.add(chars[i]);
        }
        for (Object o : set) {
            list.add(o);
        }
        int num = 0;
        for (int i = 0; i < set.size(); i++) {
            for (int j = 0; j < chars.length; j++) {
                if ( list.get(i).equals(chars[j])){
                    num++;
                }
            }
            map.put(list.get(i),num);
            num = 0;
        }
        System.out.println(set);
        System.out.println(map);
    }

    public static void t2(){
        Set set = new LinkedHashSet();
        set.add("赵云");
        set.add("马超");
        set.add("关羽");
        set.add("黄忠");
        set.add("张飞");
        set.add("张飞");

        //迭代
        Iterator iterator = set.iterator();
        while (iterator.hasNext()){
            Object next = iterator.next();
            System.out.print(next + "  ");
        }
    }
    public static void main(String[] args) {
        t2();
    }
}
